Repository navigation
Cache queries regardless of routing comments - #1752
Conversation
Routing comments do not affect the rewriter in any way, and routing happens after rewriting occurs. There's no reason we need to avoid caching these
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
I remember disabling caching for rewritten queries, but I can't remember why. Maybe the commit history around that code could help. |
|
Yeah I looked through the history but it was mixed in with massive features and provided no context around why this was the case. The struct that went into the cache did previously have the comment information on it, but that was overwritten every time it got pulled out of the cache anyway. AFAIK there hasn't ever been a time where routing information affected rewriting, and the code's current structure makes this even more apparent because the function that handles it couldn't access that information even if it wanted to |
|
I'm remembering I think. It was because the routing comment would have a different execution plan than the non-commented one, e..g, /* pgdog_shard: 0 */ would invalidate the rewrite plan. In the future, if we received a query that was rewritten and cached it anyway, the same query with a comment would hit the cache and execute the rewritten plan, not the direct-to-shard plan. I don't think this is relevant anymore since we have two different plans now: one for direct and for cross, since we moved the aggregate/ordering/etc to post-route. #1545 |
Routing comments do not affect the rewriter in any way, and routing happens after rewriting occurs. There's no reason we need to avoid caching these